package com.whmall.service.crm.module.companybusinesscertificate.enumeration;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;
import java.util.List;

/**
 * Author：yangdong
 * Date：2020/8/14
 * Description：经营证件类型
 */
public enum BusinessCertificateTypeEnum {

    /**
     * 危险化学品经营许可证
     */
    HAZARDOUS_CHEMICALS_BUSINESS_LICENSE(101, "危险化学品经营许可证"),

    /**
     * 安全生产许可证
     */
    SAFETY_PRODUCTION_LICENSE(201, "安全生产许可证"),

    /**
     * 非药品类易制毒化学品生产备案证明
     */
    NON_DRUG_PRECURSOR_PRODUCTION_RECORD(301, "非药品类易制毒化学品生产备案证明"),

    /**
     * 非药品类易制毒化学品生产二类备案证明
     */
    NON_DRUG_PRECURSOR_PRODUCTION_SECOND(302, "非药品类易制毒化学品生产二类备案证明"),

    /**
     * 非药品类易制毒化学品生产三类备案证明
     */
    NON_DRUG_PRECURSOR_PRODUCTION_THIRD(303, "非药品类易制毒化学品生产三类备案证明"),

    /**
     * 非药品类易制毒化学品经营备案证明
     */
    NON_DRUG_PRECURSOR_OPERATE_RECORD(401, "非药品类易制毒化学品经营备案证明"),

    /**
     * 非药品类易制毒化学品经营二类备案证明
     */
    NON_DRUG_PRECURSOR_OPERATE_SECOND(402, "非药品类易制毒化学品经营二类备案证明"),

    /**
     * 非药品类易制毒化学品经营三类备案证明
     */
    NON_DRUG_PRECURSOR_OPERATE_THIRD(403, "非药品类易制毒化学品经营三类备案证明"),

    /**
     * 其他
     */
    OTHER_LICENSE(901, "其他");

    public static List<Integer> hazardousChemicalsLicense() {
        return Arrays.asList(HAZARDOUS_CHEMICALS_BUSINESS_LICENSE.getValue(), SAFETY_PRODUCTION_LICENSE.getValue());
    }

    public static List<Integer> secondPrecursorLicense() {
        return Arrays.asList(NON_DRUG_PRECURSOR_PRODUCTION_RECORD.getValue(),
                NON_DRUG_PRECURSOR_OPERATE_RECORD.getValue(),
                NON_DRUG_PRECURSOR_PRODUCTION_SECOND.getValue(),
                NON_DRUG_PRECURSOR_OPERATE_SECOND.getValue());
    }

    public static List<Integer> thirdPrecursorLicense() {
        return Arrays.asList(NON_DRUG_PRECURSOR_PRODUCTION_RECORD.getValue(),
                NON_DRUG_PRECURSOR_OPERATE_RECORD.getValue(),
                NON_DRUG_PRECURSOR_PRODUCTION_THIRD.getValue(),
                NON_DRUG_PRECURSOR_OPERATE_THIRD.getValue());
    }

    public static List<Integer> precursorLicense() {
        return Arrays.asList(NON_DRUG_PRECURSOR_PRODUCTION_RECORD.getValue(), NON_DRUG_PRECURSOR_PRODUCTION_SECOND.getValue(),
                NON_DRUG_PRECURSOR_PRODUCTION_THIRD.getValue(), NON_DRUG_PRECURSOR_OPERATE_RECORD.getValue(),
                NON_DRUG_PRECURSOR_OPERATE_SECOND.getValue(), NON_DRUG_PRECURSOR_OPERATE_THIRD.getValue());
    }

    @JsonCreator
    public static BusinessCertificateTypeEnum fromNullableValue(Integer value) {
        if (null == value) {
            return null;
        }

        return fromValue(value);
    }

    public static BusinessCertificateTypeEnum fromValue(int value) {
        for (BusinessCertificateTypeEnum anEnum : values()) {
            if (anEnum.getValue() == value) {
                return anEnum;
            }
        }

        return null;
    }

    BusinessCertificateTypeEnum(int value, String name) {
        this.value = value;
        this.name = name;
    }

    private final int value;
    private final String name;

    public int getValue() {
        return value;
    }

    public String getName() {
        return name;
    }
}
